//
//  LY_Daily_TableViewCell.m
//  iSee
//
//  Created by dllo on 16/8/5.
//  Copyright © 2016年 LY. All rights reserved.
//

#import "SE_Select_TableViewCell.h"
#import "UIImageView+WebCache.h"
#import "SE_Item_Model.h"


#define WIDTH self.contentView.bounds.size.width
#define HEIGHT self.contentView.bounds.size.height

@interface SE_Select_TableViewCell()

@property (nonatomic, retain) UIImageView *coverImage;
@property (nonatomic, retain) UILabel *titleLabel;
@property (nonatomic, retain) UILabel *descLabel;

@end

@implementation SE_Select_TableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.coverImage = [[UIImageView alloc]init];
        [self.contentView addSubview:self.coverImage];
        
        self.descLabel = [[UILabel alloc]init];
        self.descLabel.textColor = [UIColor whiteColor];
        self.descLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.descLabel];
        
        self.titleLabel = [[UILabel alloc]init];
        
        self.titleLabel.font = [UIFont boldSystemFontOfSize:25];
        self.titleLabel.textColor = [UIColor whiteColor];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.titleLabel];
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.coverImage.frame = self.contentView.bounds;
    self.titleLabel.frame = CGRectMake(0, self.contentView.center.y, WIDTH, 25);
    self.descLabel.frame = CGRectMake(0, self.contentView.center.y + 40, WIDTH, 25);
}

-(void)setItemModel:(SE_Item_Model *)itemModel{
    _itemModel = itemModel;
    [self.coverImage sd_setImageWithURL:[NSURL URLWithString:itemModel.feed] placeholderImage:[UIImage imageNamed:@"holder"]];
    self.titleLabel.text = itemModel.title;
    
    NSInteger time = itemModel.duration.integerValue;
    NSInteger min = time / 60;
    int sec = time % 60;
    
    self.descLabel.text = [NSString stringWithFormat:@"#%@  /  %ld'%d'", itemModel.category, min, sec];
}




@end




















